{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# For Loops [demonstration]\n",
    "The code below demonstrates two ways of looping through the numbers 0,1,2,3,4,5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 - demonstrating for loop\n",
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "print(\"1 - demonstrating for loop\")\n",
    "for i in [0,1,2,3,4,5]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 - demonstrating for loop with range()\n",
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n",
      "5\n"
     ]
    }
   ],
   "source": [
    "print(\"2 - demonstrating for loop with range()\")\n",
    "for i in range(6):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The `range` function\n",
    "The `range` function is one you'll probably use a lot - often in conjunction with a for loop. The code below shows how you can use the range function to print out a multiplication table.\n",
    "\n",
    "Read through the code below. What is the biggest number you expect to see printed? "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 x 0 = 0\n",
      "0 x 1 = 0\n",
      "0 x 2 = 0\n",
      "0 x 3 = 0\n",
      "0 x 4 = 0\n",
      "1 x 0 = 0\n",
      "1 x 1 = 1\n",
      "1 x 2 = 2\n",
      "1 x 3 = 3\n",
      "1 x 4 = 4\n",
      "2 x 0 = 0\n",
      "2 x 1 = 2\n",
      "2 x 2 = 4\n",
      "2 x 3 = 6\n",
      "2 x 4 = 8\n",
      "3 x 0 = 0\n",
      "3 x 1 = 3\n",
      "3 x 2 = 6\n",
      "3 x 3 = 9\n",
      "3 x 4 = 12\n",
      "4 x 0 = 0\n",
      "4 x 1 = 4\n",
      "4 x 2 = 8\n",
      "4 x 3 = 12\n",
      "4 x 4 = 16\n"
     ]
    }
   ],
   "source": [
    "for left_num in range(5):\n",
    "    for right_num in range(5):\n",
    "        product = left_num * right_num\n",
    "        print(left_num, \"x\", right_num, \"=\", product)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
